from user.models import *


# 0 -> 未分配， 1 -> 学生， 2 -> 管理员
def get_user_role(user):
    role = 0
    if Student.objects.filter(user__username=user.username).count() > 0:
        role += 1
    if Manager.objects.filter(user__username=user.username).count() > 0:
        role += 2
    return role


def is_user_student(user):
    role = get_user_role(user)
    if role == 1 or role == 3:
        return True


def is_user_manager(user):
    role = get_user_role(user)
    if role == 2 or role == 3:
        return True

